#ifndef HEAD_H
#define HEAD_H
//服务器头文件
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/select.h>
#include <time.h>
#include <sys/wait.h>
#include <dirent.h>
#include <syslog.h>
#include <sys/shm.h>
#include <sys/ipc.h>
#include <signal.h>
#include <sys/time.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/epoll.h>
#include <sys/sendfile.h>
#include <mysql/mysql.h>
#include <crypt.h>
#define ARGS_CHECK(argc, expected)\
    do {\
        if ((argc) != (expected)) {\
            fprintf(stderr, "args num error!\n");\
	    exit(1);\
        }\
    } while (0)                      

#define ERROR_CHECK(ret, error_flag, msg)\
    do {\
        if ((ret) == (error_flag)) {\
            perror(msg);\
            exit(1);\
        }\
    } while (0)

#define THREAD_ERROR_CHECK(ret,msg) {if(ret!=0){fprintf(stderr,"%s:%s\n",msg,strerror(ret));}}
 

enum command {
    client_exit= 0,
    client_login = 1,
    create_account = 2,
    cd = 3,
    ls = 4,
    pwd = 5,//服务器不处理pwd，这里仅占位
    upload = 6,
    download = 7,
    rm = 8,
    cdir = 9
};

typedef struct msg_s{
    char user_name[255];
    int cur_id;
    char argv[1024];
    enum command cmd;
    char token[512];
}MSG;

int initTcpLink(int *socket_fd,char *ip,char *port);
int addtoEpoll(int epoll_fd, int socket_fd);
int delfromEpoll(int epoll_fd, int socket_fd);


#endif
